<template>
	<view>
		
		<!-- <ElSearch :value="searchText" @input="(data)=>{searchText=data}"></ElSearch> -->
		<el-search v-model="searchText"></el-search>
		<view v-for="item in searchList" :key="item.id">
			
			<HouseItem :item="item"></HouseItem>
		</view>
	</view>
</template>

<script>
	import ElSearch from "@/components/el-search.vue"
		import {searchHouse} from '@/api/home.js'
		import HouseItem from '@/components/house-item.vue'
	export default {
		components:{
			ElSearch,
			HouseItem
		},
		data() {	
			return {
				searchText:'',
				searchList:[]
			};
		},
		watch:{
			searchText(newVal){
				//发送axios请求
				if(newVal){
					this.search()
				}
				
			}
		},
		methods:{
			async search(){
				let data = {
					searchkey:this.searchText
				}
				let res =  await searchHouse(data)
				this.searchList = res.data.map(item=>{
					item.tabs =JSON.parse( item.tabs.replace(/'/g,'"'));
					return item;
				})
				
				
				
				console.log(res);
			}
		},
	}
</script>

<style lang="scss">

</style>
